<?php
require_once '../utils/common.php';
require_once '../Config.php';
$conn = mysql_connect ( host, username, password );
if (! $conn) {
	die ( "连接失败" . mysql_error () );
}
mysql_select_db ( db, $conn );
$flag = $_REQUEST ['flag'];
if ($flag == "add") {
	$title = $_REQUEST ["title"];
	$content = $_POST ["content"];
	$sql = "set names utf8";
	mysql_query ( $sql );
	$sql = "insert into j_tab_xuexi(title, content) values ('" . $title . "','" . $content . "')";
	mysql_query ( $sql );
	mysql_close ( $conn );
	echo "<script>alert('添加成功!');self.location='XuexiManager.php';</script>";
} else if ($flag == 'del') {
	$id = $_REQUEST ['id'];
	$sql = "delete from j_tab_xuexi where id=" . $id;
	mysql_query ( $sql );
	mysql_close ( $conn );
	echo "<script language=\"JavaScript\">\r\n";
	echo " alert(\"删除成功\");\r\n";
	echo " history.back();\r\n";
	echo "</script>";
	exit ();
} else if ($flag == 'update') {
	$id = $_REQUEST ['id'];
	$title = $_REQUEST ["title"];
	$content = $_POST ["content"];
	$sql = "set names utf8";
	mysql_query ( $sql );
	$sql = "update j_tab_xuexi set content='" . $content . "',title='" . $title . "' where id=" . $id;
	mysql_query ( $sql );
	mysql_close ( $conn );
	echo "<script>alert('修改成功!');self.location='XuexiManager.php';</script>";
}

?>